<div class="bjui-pageHeader">
<form id="pagerForm" data-toggle="ajaxsearch" action="__URL__" method="get">
	<input type="hidden" name="pageSize" value="{$numPerPage}">
    <input type="hidden" name="pageCurrent" value="{$_REQUEST['pageNum']|default=1}">
        <div class="bjui-searchBar">
			<label>时间：</label><input type='text' data-toggle='datepicker' value='{$_REQUEST['time1']}' name='time1' class='form-control' size='12' />-<input type='text' data-toggle='datepicker' value='{$_REQUEST['time2']}' name='time2' class='form-control' size='12' />
			&nbsp;<label>业务员：</label><select name='jingban' data-toggle='selectpicker'><option value=''>全部</option><foreach name='jingbanlist' item='v'><option value='{$v.jingban}'  <if condition="$v.jingban EQ $_REQUEST['jingban']">selected<else/>{$_REQUEST['jingban']}</if> >{$v.jingban}</option></foreach></select>&nbsp;
             <button type="submit"  class="btn-default" data-icon="search">查询</button>
             <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);" data-icon="undo">清空查询</a>
			 <php>if(display(CONTROLLER_NAME.'/dayin')){</php><span style="float:right;margin-right:5px;"><a href="{:U('tjhetong/dayin',array('time1'=>$_REQUEST['time1'],'time2'=>$_REQUEST['time2'],'jingban'=>$_REQUEST['jingban']))}" target="_blank" class="btn btn-blue" data-icon="print">打印</a></span><php>}</php>
		</div> 
</form>
    
</div>
<div class="bjui-pageContent tableContent">
     <table data-toggle="tablefixed" data-width="100%" data-layout-h="0" data-nowrap="true">
            <thead>
<tr>
<th rowspan="2">统计时间</th>
<th rowspan="2">合同总金额</th>
<th rowspan="2">已回款</th>
<th rowspan="2">待回款</th>
<th rowspan="2">已开票</th>
<th rowspan="2">已付款/支出</th>
<th colspan="2" align="center">统计</th>
</tr>
<tr>
<th>实际收款</th>
<th>实际付款</th>
</tr>
            </thead>
            <tbody>
<php>
if(isset($_REQUEST['jingban']) && $_REQUEST['jingban'] != ''){
	  $jingban=" and jingban='".$_REQUEST['jingban']."'";
	}
if(isset($_REQUEST['time1']) && $_REQUEST['time1'] != ''&&isset($_REQUEST['time2']) && $_REQUEST['time2'] != ''){
  $nian=substr($_REQUEST['time1'],0,4);
  }else{
  $nian=date("Y",time());
}
if(isset($_REQUEST['time1']) && $_REQUEST['time1'] != ''&&isset($_REQUEST['time2']) && $_REQUEST['time2'] != ''){
</php>
<!---////////////搜索///////--->
<tr>
<td>{$_REQUEST['time1']}-{$_REQUEST['time2']} {$_REQUEST['jingban']}</td>
<td><php>echo M('hetong')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('jine');</php></td>
<td><php>echo M('hetong')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('yishou');</php></td>
<td><php>echo M('hetong')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('weishou');</php></td>
<td><php>echo M('hetong')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('kaipiao');</php></td>
<td><php>echo M('hetong')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('yifu');</php></td>
<td><php>echo M('shou')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('jine');</php></td>
<td><php>echo M('fukuan')->where("addtime > '".$_REQUEST['time1']." 00:00:00' and addtime < '".$_REQUEST['time2']." 59:59:59'".$jingban)->sum('jine');</php></td>
</tr>
<Tr><Td colspan="8" height="50"></td></tr>
<!---////////////搜索///////--->
<php>
}
for ($i=1;$i<13;$i+=1){
</php>
<tr>
<td>{$nian}年{$i}月</td>
<td><php>
if($i<10){
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('jine');
}else{
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('jine');
}
</php></td>
<td><php>
if($i<10){
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('yishou');
}else{
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('yishou');
}
</php></td>
<td><php>
if($i<10){
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('weishou');
}else{
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('weishou');
}
</php></td>
<td><php>
if($i<10){
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('kaipiao');
}else{
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('kaipiao');
}
</php></td>
<td><php>
if($i<10){
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('yifu');
}else{
echo M('hetong')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('yifu');
}
</php></td>
<td><php>
if($i<10){
echo M('shou')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('jine');
}else{
echo M('shou')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('jine');
}
</php></td>
<td><php>
if($i<10){
echo M('fukuan')->where("addtime like '%".$nian."-%' and addtime like '%0".$i."-%'".$jingban)->sum('jine');
}else{
echo M('fukuan')->where("addtime like '%".$nian."-%' and addtime like '%".$i."-%'".$jingban)->sum('jine');
}
</php></td>
         </tr> 
<php>}</php>
            </tbody>
        </table>
</div>
<div class="bjui-pageFooter">
    <ul>
       <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
    </ul>
</div>